#include "Alignment.cpp"
#include "MakeComparable.cpp"
#include "ParseFile.cpp"
#include <cctype>
#include <fstream>
#include <sstream>
#include <utility>
#include <vector>

using namespace std;

vector< pair < int, int > > compareFile(string pathA, string pathB, int cMethod)
{
	string t;
	ifstream fileA(pathA.c_str());
	ifstream fileB(pathB.c_str());
	string parsedA = "";
	string parsedB = "";
	istringstream ssA, ssB;
	vector<pair <int, int> > c;

	t = pathA.substr(pathA.size()-4);
	
	if (t == "docx")
		parsedA = parseDocx(pathA.c_str());
	if (t == ".odt")
		parsedA = parseODT(pathA.c_str());
	if (t == ".rtf")
		parsedA = parseRTF(pathA.c_str());

	t = pathB.substr(pathB.size()-4);
	
	if (t == "docx")
		parsedB = parseDocx(pathB.c_str());
	if (t == ".odt")
		parsedB = parseODT(pathB.c_str());
	if (t == ".rtf")
		parsedB = parseRTF(pathB.c_str());

	ssA.str(parsedA);
	ssB.str(parsedB);

	if (!(parsedA.size()) && !(parsedB.size()))
	{
		switch(cMethod)
		{
			case 1:
				c = alignComparables(makeVecGeneralComparable(fileA), makeVecGeneralComparable(fileB));
				break;
			case 2:
				c = alignComparables(makeVecNumberComparable(fileA), makeVecNumberComparable(fileB));
				break;
			case 3:
				c = alignComparables(makeVecSpecialComparable(fileA), makeVecSpecialComparable(fileB));
				break;
			case 4:
				c = alignComparables(makeVecWSComparable(fileA), makeVecWSComparable(fileB));
				break;
		}
	}

	else if ((parsedA.size()) && !(parsedB.size()))
	{
		switch(cMethod)
		{
			case 1:
				c = alignComparables(makeVecGeneralComparable(ssA), makeVecGeneralComparable(fileB));
				break;
			case 2:
				c = alignComparables(makeVecNumberComparable(ssA), makeVecNumberComparable(fileB));
				break;
			case 3:
				c = alignComparables(makeVecSpecialComparable(ssA), makeVecSpecialComparable(fileB));
				break;
			case 4:
				c = alignComparables(makeVecWSComparable(ssA), makeVecWSComparable(fileB));
				break;
		}
	}

	else if (!(parsedA.size()) && (parsedB.size()))
	{
		switch(cMethod)
		{
			case 1:
				c = alignComparables(makeVecGeneralComparable(fileA), makeVecGeneralComparable(ssB));
				break;
			case 2:
				c = alignComparables(makeVecNumberComparable(fileA), makeVecNumberComparable(ssB));
				break;
			case 3:
				c = alignComparables(makeVecSpecialComparable(fileA), makeVecSpecialComparable(ssB));
				break;
			case 4:
				c = alignComparables(makeVecWSComparable(fileA), makeVecWSComparable(ssB));
				break;
		}
	}

	else
	{
		switch(cMethod)
		{
			case 1:
				c = alignComparables(makeVecGeneralComparable(ssA), makeVecGeneralComparable(ssB));
				break;
			case 2:
				c = alignComparables(makeVecNumberComparable(ssA), makeVecNumberComparable(ssB));
				break;
			case 3:
				c = alignComparables(makeVecSpecialComparable(ssA), makeVecSpecialComparable(ssB));
				break;
			case 4:
				c = alignComparables(makeVecWSComparable(ssA), makeVecWSComparable(ssB));
				break;
		}
	}

	return c;		
}
